package pt.utl.ist.ginger3d.domain;

import java.util.HashMap;
import java.util.Map;

public abstract class Tag {

	private Map<String, String> properties;
	private String name;
	
	public Tag(String name, Map<String, String> properties) {
		this.properties = properties;
		this.name = name;
	}
	
	protected abstract String[] getRequiredProperties();
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public void updateProperty(String key, String value) {
		properties.put(key, value);
	}
	
	public String getProperty(String key) {
		return properties.get(key);
	}
	
	public Map<String, String> getProperties() {
		return properties;
	}
	
	protected void setProperties(HashMap<String, String> properties) {
		this.properties = properties;
	}
	
	public final void updateProperties(Map<String, String> properties, boolean override) {
		
		for(Map.Entry<String, String> entry : properties.entrySet()) {
			if(override == true || !this.properties.containsKey(entry.getKey()))
				updateProperty(entry.getKey(), entry.getValue());
		}
	}
}
